package ee.falcon.xml;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.jdom2.Document;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;

import ee.falcon.util.ErrorMessager;

public class ModifiedXMLOutputter 
{
	private XMLOutputter xmlOutput;
	
	public void output(Document document, String filename)
	{
		xmlOutput = new XMLOutputter(Format.getPrettyFormat());
		
		try 
		{
			xmlOutput.output(document, new FileOutputStream(
					new File(filename)));
		} 
		catch (FileNotFoundException e) 
		{
			new ErrorMessager().errorMsg("Specified file: " + filename + " was not found!", e);
		} 
		catch (IOException e) 
		{
			new ErrorMessager().errorMsg(ErrorMessager.ERR004R_IO_ERROR, e);
		} 
	}
}
